package com.mouse.hxsj.service;

import com.mouse.damo.micro.*;
import com.mouse.damo.util.LogUtil;
import com.mouse.hxsj.entity.enums.MapPlace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class FlyService {
    public static void main(String[] args) {
        Com com = new Com();
        com.setResourcePath("D:/damo");
        boolean bind = com.bind(4000942);
        System.out.println(bind);
        for (MapPlace place : MapPlace.values()) {
            new FlyService().fly(com, place);
            Sleep.sleep(12 * 1000);
        }

    }

    public void fly(Com com, MapPlace place) {
        if (place == null) return;
        Press press = new Press(com);
        press.keyPress(Press.F1);
        Sleep.sleep(350);
        FindPic findPic = new FindPic(com);
        Window window = new Window(com);
        int[] windowRect = window.getClientSize(com.getHwnd());
        int height = windowRect[2], width = windowRect[1];
        int[] picPic = findPic.findPic(0, 0, width, height
                , "login/飞来飞去.bmp", "203040", 0.8, 0);
        if(picPic[0]==-1)return;
        LogUtil.logArray(picPic);
        Mouse mouse = new Mouse(com);
        mouse.mouseDoubleClick(picPic[1], picPic[2] + place.getY1());
        Sleep.sleep(350);
        if (place.getY2() > 0) mouse.mouseDoubleClick(picPic[1], picPic[2] + place.getY2());
        log.info("飞来飞去成功");
    }
}
